using System;
using UnityEngine;
using Unity.VisualScripting;
using UnityGameFramework.Runtime;
using ResourceApplyFailureEventArgs = UnityGameFramework.Runtime.ResourceApplyFailureEventArgs;

namespace LS.UGFUnits
{
    [UnitShortTitle("Resource Apply")]
    [UnitSurtitle("Failure")]
    public sealed class ResourceApplyFailure : FrameworkEventUnit<ResourceApplyFailureEventArgs>
    {
        protected override int EventId => ResourceApplyFailureEventArgs.EventId;
        protected override string HookName => UGFHookNames.ResourceApplyFailure;

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput Name
        {
            get;
            private set;
        }
        
        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput ResourcePackPath
        {
            get;
            private set;
        }


        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput ErrorMessage
        {
            get;
            private set;
        }


        protected override void Definition()
        {
            base.Definition();
            Name = ValueOutput<string>(nameof(Name));
            ResourcePackPath = ValueOutput<string>(nameof(ResourcePackPath));
            ErrorMessage = ValueOutput<string>(nameof(ErrorMessage));
        }

        protected override void AssignArguments(Flow flow, ResourceApplyFailureEventArgs args)
        {
            base.AssignArguments(flow, args);
            flow.SetValue(Name, args.ResourcePackPath);
            flow.SetValue(ResourcePackPath, args.ErrorMessage);
            flow.SetValue(ErrorMessage, args.ErrorMessage);
        }
    }
}